<template>
  <van-dialog v-model="isShow" :title="titleText" show-cancel-button @close="close" @confirm="confirm">
    <slot name="oldPwd"/>
    <slot name="newPwd"/>
  </van-dialog>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'Dialog',
  props: {
    show: {
      type: Boolean,
      required: true,
      default: false
    },
    title: {
      type: String,
      required: true,
      default: ''
    },
    parentValue: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // errorMessage: ''
    }
  },
  computed: {
    ...mapState({
      userInfo: state => state.user.userInfo
    }),
    isShow: {
      get() {
        return this.show
      },
      set() {
        this.$emit('handleCancel', false)
      }
    },
    titleText: {
      get() {
        return this.title
      }
    },
    parentToChild: {
      get() {
        return this.parentValue
      },
      set() {
        this.$emit('setValue', this.parentValue)
      }
    }
  },
  methods: {
    close() {
      this.$emit('dialogClosed')
    },
    confirm() {
      this.$emit('dialogConfirm')
    }
  }
}
</script>

<style scoped lang="less">

</style>
